﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using FTchina;

public partial class UI_siteconfig : System.Web.UI.Page
{
    FTchina.SiteConfig.SiteInfo si = new FTchina.SiteConfig.SiteInfo();

    protected void Page_Load(object sender, EventArgs e)
    {
        basic.CheckAdmin(this);
        basic.ChkPoewr(this, FTchina.Api.htmlpath.GetCurrentPagePath());
        if (!IsPostBack)
        {
            txbsiteurl.Text = si.SiteUrl;
            txbcachesj.Text = si.CacheTime;
            txbindex.Text = si.IndexRedirect;
            txbsitename.Text = si.SiteName;
            txbqdh.Text = si.QianDaohang;
            txbhdh.Text = si.HouDaohang;
            txblogo.Text = si.SiteLogo;
            txbbanner.Text = si.SiteBanner;
            txbmeta.Text = si.UserMeta;
            txbbottom.Text = si.SiteBottom;
            ddlishtml.SelectedValue = si.IsHtml.ToString();
            txbRefresh.Text = si.RefreshTime;
            ddlcounter.Text = si.Counter.ToString();
         }
    }

    private void GetSiteUrl()
    {
        string url = this.Request.Url.AbsoluteUri;
        this.lblsiteurl.Text = "建议参考值" + url.Replace("ui/siteconfig.aspx", "");
    }

    protected void btnok_Click(object sender, EventArgs e)
    {
        string siteurl = basic.FilterSQL(txbsiteurl.Text);
        string cachesj = basic.FilterSQL(txbcachesj.Text);
        string indexredict = basic.FilterSQL(txbindex.Text);
        string sitename = basic.FilterSQL(txbsitename.Text);
        string qiandaohang = basic.SafeRequest(txbqdh.Text);
        string houdaohang = basic.SafeRequest(txbhdh.Text);
        string banner = basic.SafeRequest(txbbanner.Text);
        string logo = basic.SafeRequest(txblogo.Text);
        string meta = basic.SafeRequest(txbmeta.Text);
        string bottom = basic.SafeRequest(txbbottom.Text);
        string RefreshTime = basic.SafeRequest(txbRefresh.Text);
        if (siteurl.Length == 0 || cachesj.Length == 0 || indexredict.Length == 0 || sitename.Length == 0)
        {
            JS.Alert("请检查输入！不能有空值");
            return;
        }
        if (!FTchina.PageValidate.IsNumber(cachesj)) { JS.Alert("请在缓存时间框输入数字"); return; }

         si.CacheTime = cachesj;
        si.IndexRedirect = indexredict;
        si.SiteName = sitename;
        si.SiteUrl = siteurl;
        si.QianDaohang = qiandaohang;
        si.HouDaohang = houdaohang;
        si.SiteLogo = logo;
        si.SiteBanner = banner;
        si.IsHtml =Convert.ToBoolean(ddlishtml.SelectedValue);
        si.UserMeta = meta;
        si.SiteBottom = bottom;
        si.RefreshTime = RefreshTime;
        si.Counter = Convert.ToBoolean(ddlcounter.SelectedValue);
        UImsg.PageRender(true);
    }

}
